package com.example.other.controller;

import com.example.authority.common.entity.Result;
import com.example.authority.common.utils.SecurityUtils;
import com.example.other.domain.Chat;
import com.example.other.domain.UsersInfo;
import com.example.other.service.ChatService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class ChatController {
    @Autowired
    private AmqpTemplate amqpTemplate;

    @Autowired
    ChatService chatService;
    @GetMapping("chat/user")
    public Result chatUser() {
        List<UsersInfo> l= chatService.getChatedUsersByDoctorId(Math.toIntExact(SecurityUtils.getCurrentUser().getUser().getId()));
        return Result.succ(l);
    }
    @GetMapping("chat/user/{doctorId}")
    public Result chatDoctorUser(@PathVariable("doctorId") Integer cosId) {
        List<Chat> l= chatService.getChatListByDoctorIdAndUserId(Math.toIntExact(SecurityUtils.getCurrentUser().getUser().getId()),cosId);
        return Result.succ(l);
    }
}
